case EXIT_REASON_TASK_SWITCH: {
const enum hvm_task_switch_reason reasons[] = {
TSW_call_or_int, TSW_iret, TSW_jmp, TSW_call_or_int };
- int32_t errcode = -1;
+ int32_t ecode = -1, source;
exit_qualification = __vmread(EXIT_QUALIFICATION);
- if ( (idtv_info & INTR_INFO_VALID_MASK) &&
- (idtv_info & INTR_INFO_DELIVER_CODE_MASK) )
- errcode = __vmread(IDT_VECTORING_ERROR_CODE);
- hvm_task_switch((uint16_t)exit_qualification,
- reasons[(exit_qualification >> 30) & 3],
- errcode);
+ source = (exit_qualification >> 30) & 3;
+ inst_len = __get_instruction_length(); /* Safe: See SDM 3B 23.2.4 */
+ if ( (source == 3) && (idtv_info & INTR_INFO_VALID_MASK) )
+ {
+ /* ExtInt, NMI, HWException: no instruction to skip over. */
+ if ( !(idtv_info & (1u<<10)) ) /* 0 <= IntrType <= 3? */
+ inst_len = 0;
+ /* If there's an error code then we pass it along. */
+ if ( idtv_info & INTR_INFO_DELIVER_CODE_MASK )
+ ecode = __vmread(IDT_VECTORING_ERROR_CODE);
+ }
+ regs->eip += inst_len;
+ hvm_task_switch((uint16_t)exit_qualification, reasons[source], ecode);
break;
}
case EXIT_REASON_CPUID: